﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using Microsoft.Phone.Tasks;

namespace PNut_Project_Lin
{
    public partial class DetailPage : PhoneApplicationPage
    {

        string Name;
        string Detail;
        string img;
        string Link;

        public DetailPage()
        {
            InitializeComponent();
        }

        private void LinkBt_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MediaPlayerLauncher videox = new MediaPlayerLauncher();
                videox.Media = new Uri(Link, UriKind.Absolute);
                videox.Location = MediaLocationType.None;
                videox.Orientation = MediaPlayerOrientation.Landscape;
                videox.Show();
            }catch(Exception ex){ MessageBox.Show(ex.Message);}
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.TryGetValue("Name", out Name))
            {
                PageTitle.Text = Name;
            }

            if (NavigationContext.QueryString.TryGetValue("Detail", out Detail))
            {
                DetailTb.Text = Detail;
            }

            if (NavigationContext.QueryString.TryGetValue("img", out img))
            {
                BitmapImage x = new BitmapImage(new Uri(img, UriKind.Relative));
                Img.Source = x;
            }

            if (NavigationContext.QueryString.TryGetValue("Link", out Link))
            {

            }


        }

        private void Img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            try
            {
                MediaPlayerLauncher videox = new MediaPlayerLauncher();
                videox.Media = new Uri(Link, UriKind.Absolute);
                videox.Location = MediaLocationType.None;
                videox.Orientation = MediaPlayerOrientation.Landscape;
                videox.Show();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
    }
}